using System;
using System.Diagnostics.Contracts;

namespace OpenWaves.Reflection
{
    public static class TypeExtensions
    {
        [Pure]
        public static bool Is<T>(this Type type)
        {
            Contract.Requires<ArgumentNullException>(type != null);

            return typeof (T).IsAssignableFrom(type);
        }

        public static bool IsNullable(this Type type)
        {
            Contract.Requires<ArgumentNullException>(type != null);

            return Nullable.GetUnderlyingType(type) != null;           
        }
    }
}